package com.mikgonz.farkle.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mikgonz.farkle.R;

public class TextInputDialog extends Activity {

	public static final int ADD_FRIEND_REQUEST_CODE = 1;
	public static final String TITLE = "title";
	public static final String TEXT = "text";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.edittext_dialog);

		Bundle extras = getIntent().getExtras();
		String title = extras.getString(TITLE);
		((TextView) findViewById(R.id.edittext_dialog_title)).setText(title);
		// TODO grab from intent the text for the pos button and the neg button
	}

	public void onAdd(View v) {
		EditText e = (EditText) findViewById(R.id.edittext_dialog_edit);
		Intent i = new Intent();
		String name = e.getText().toString().toLowerCase().trim();
		i.putExtra(TEXT, name);
		setResult(RESULT_OK, i);
		finish();
	}

	public void onCancel(View v) {
		setResult(RESULT_CANCELED);
		finish();
	}

}
